<?php
/**
 * Created by PhpStorm.
 * User: Dave
 * Date: 2018/7/24
 * Time: 11:02
 */

ini_set('display_errors', 1);
error_reporting(-1);
require_once '/data/wwwroot/g_vendor/autoload.php';

use Biz\model\activity\FlashSale as mFlashSale;
use Biz\cache\FlashSale as cFlashSale;
use Biz\service\activity\FlashSale as sFlashSale;

$time = date('Y-m-d H:i:s');

// 查询当前是否有限时购
$flashSaleInfo = mFlashSale::getFalseSaleIngInfo($time, ['id', 'start_time', 'end_time']);

if ($flashSaleInfo) {
    $expire =  strtotime($flashSaleInfo['end_time']) - time();
    cFlashSale::delFlashSale(sFlashSale::$isFlashSale);
    $result = cFlashSale::setFlashSale($flashSaleInfo, $expire, sFlashSale::$isFlashSale);
    if ($result) {
        echo printf("%s,%s",date('Y-m-d H:i:s'),'限时购数据同步成功');
    }
}
